/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.component.gateway.dianlan.bits;

import info.peigen.hotpot.component.gateway.dianlan.bits.base.BitParserBase;
import info.peigen.hotpot.component.gateway.dianlan.protocol.passive.DianlanBatteryTemperatureInfo;

/**
 * <b>(DianlanBatteryTemperatureInfoReasonBits)</b>
 * <p>
 * 单体电池温度信息-解析
 *
 * @author LiDaHai
 * @version 1.0.0
 * @since 2023/1/12
 */
public class DianlanBatteryTemperatureInfoReasonBits extends BitParserBase {

    public DianlanBatteryTemperatureInfo parseReason(String hexString) {
        String[]                      hexStrArray = hexStrToArray(hexString);
        DianlanBatteryTemperatureInfo info        = DianlanBatteryTemperatureInfo.builder().build();
        info.setHighestTemperature(parseInt(hexStrArray[0]) + (-40));
        info.setHighestRatedCapacity(4 * parseInt(hexStrArray[1]));
        info.setHighestTemperatureNumber(parseInt(hexStrArray[2]) + "");
        info.setLowestTemperature(parseInt(hexStrArray[3]) + (-40));
        info.setLowestRatedCapacity(2 * parseInt(hexStrArray[4]));
        info.setLowestTemperatureNumber(parseInt(hexStrArray[5]) + "");
        info.setChargeCurrentLimit(4 * parseInt(hexStrArray[6]));
        info.setDischargeCurrentLimit(4 * parseInt(hexStrArray[7]));
        return info;
    }
}